#include <iostream>
#include <cstring>
using namespace std;
char a[10002], b[10002];
int i, j, ans = 1, len;
int main()
{
    scanf("%s\n%s", &a, &b);
    len = strlen(a);
    for (i = 0; i <= len - 2; i++)
        for (j = 0; j <= len - 1; j++)
            if (b[j] == a[i] && b[j - 1] == a[i + 1])
                ans *= 2;
    cout << ans;
    return 0;
}